package com.wad.manager.controller;

import com.wad.entity.system.SysMenu;
import com.wad.manager.service.SysMenuService;
import com.wad.vo.common.Result;
import com.wad.vo.common.ResultCodeEnum;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author wad
 * @date 2023/12/04 9:45
 * @project e-commerce
 **/
@RequestMapping(value = "/admin/system/sysMenu")
@RestController
public class SysMenuController {


    @Resource
    private SysMenuService sysMenuService;


    //菜单列表
    @GetMapping("/findNodes")
    public Result findNodes(){
        List<SysMenu> sysMenuList=sysMenuService.findNodes();
        return Result.build(sysMenuList, ResultCodeEnum.SUCCESS);
    }


    //菜单添加
    @PostMapping("/save")
    public Result save(@RequestBody SysMenu sysMenu){
        sysMenuService.save(sysMenu);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }

    //菜单修改
    @PutMapping("/update")
    public Result update(@RequestBody SysMenu sysMenu){
        sysMenuService.update(sysMenu);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }

    //菜单删除
    @DeleteMapping("/deleteById/{menuId}")
    public Result deleteById(@PathVariable Long menuId){
        sysMenuService.deleteById(menuId);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }
}
